package com.dashuai.modbus.core.master;

import com.dashuai.modbus.param.BatchReadParam;
import com.serotonin.modbus4j.exception.ErrorResponseException;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *
 * </p>
 *
 * @author QM
 * @date 2024/4/29
 */
public interface ModbusBaseTCPMaster extends ModbusBaseMaster {


    Boolean readCoilStatus(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Boolean readInputStatus(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Number readHoldingRegister(String ip, int port, int slaveId, int offset, int dataType) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    <T> T readHoldingRegister(String ip, int port, int slaveId, int offset, int dataType, Class<T> returnType) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Number readInputRegisters(String ip, int port, int slaveId, int offset, int dataType) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    <T> T readInputRegisters(String ip, int port, int slaveId, int offset, int dataType, Class<T> returnType) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Short read03Short(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Short read03UnsignedShort(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Integer read03Int(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Integer read03IntInverse(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Integer read03IntUnsigned(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Integer read03IntUnsignedInverse(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Long read03Long(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Long read03LongInverse(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Long read03LongUnsigned(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Long read03LongUnsignedInverse(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Float read03FloatABCD(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Float read03Float(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Float read03FloatCDAB(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Float read03FloatInverse(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Double read03DoubleABCDEFGH(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Double read03Double(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    Double read03DoubleGHEFCDAB(String ip, int port, int slaveId, int offset) throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    Double read03DoubleInverse(String ip, int port, int slaveId, int offset) throws ModbusTransportException, ErrorResponseException, ModbusInitException;

    <T> Map<Integer, T> batchRead(String ip, int port, int slaveId, List<Integer> offsetList, int dataType, Class<T> returnType)
            throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    <T> Map<Integer, T> batchRead(String ip, int port, List<BatchReadParam> batchReadParamList, int dataType, Class<T> returnType)
            throws ErrorResponseException, ModbusTransportException, ModbusInitException;

    boolean writeCoil(String ip, int port, int slaveId, int writeOffset, boolean writeValue)
            throws ModbusTransportException, ModbusInitException;

    boolean batchWriteCoil(String ip, int port, int slaveId, int startOffset, boolean[] writeValueArr)
            throws ModbusTransportException, ModbusInitException;

    boolean writeRegister(String ip, int port, int slaveId, int writeOffset, short writeValue)
            throws ModbusTransportException, ModbusInitException;

    boolean batchWriteRegister(String ip, int port, int slaveId, int startOffset, short[] writeValueArr)
            throws ModbusTransportException, ModbusInitException;

    void writeHoldingRegister(String ip, int port, int slaveId, int offset, Number value, int dataType)
            throws ModbusTransportException, ErrorResponseException, ModbusInitException;
}
